package com.zzsy.carosshopprojects.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.king.base.adapter.ViewHolderRecyclerAdapter;
import com.king.base.adapter.holder.ViewHolder;
import com.yatoooon.screenadaptation.ScreenAdapterTools;
import com.zzsy.carosshopprojects.R;
import com.zzsy.carosshopprojects.base.ConfigureFile;
import com.zzsy.carosshopprojects.bean.ActivityBean;
import com.zzsy.carosshopprojects.util.StringUtils;
import com.zzsy.carosshopprojects.util.ViewBgUtil;

import java.util.List;

import androidx.constraintlayout.widget.ConstraintLayout;

public class ChoseActivityAdapter extends ViewHolderRecyclerAdapter<ActivityBean> {

    public ChoseActivityAdapter(Context context, List<ActivityBean> listData, int layoutId) {
        super(context, listData, layoutId);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.adapter_choseactivity, null);
        ScreenAdapterTools.getInstance().loadView(view);
        return view;
    }

    @Override
    public void bindViewDatas(ViewHolder helper, ActivityBean bean, int positions) {
        ConstraintLayout constraintLayout = helper.getView(R.id.cl);
        constraintLayout.setBackground(ViewBgUtil.setBg(10, Color.parseColor(ConfigureFile.ColorWhite)));

        if (bean.getServiceCardDTOList() != null && bean.getServiceCardDTOList().size() > 0) {
            helper.setText(R.id.tv_zengzhi_size, "x" + bean.getServiceCardDTOList().size());
        } else {
            helper.setText(R.id.tv_zengzhi_size, "x0");
        }


        if (bean.getCouponList() != null && bean.getCouponList().size() > 0) {
            helper.setText(R.id.tv_coupon_size,"x" + bean.getCouponList().size());
        } else {
            helper.setText(R.id.tv_coupon_size,"x0");
        }
        String activityName = bean.getActivityName();
        if (!StringUtils.isEmpty(activityName)) {
           helper.setText(R.id.tv_activity_name,activityName);
        }
        String activitySummary = bean.getActivitySummary();
        if (!StringUtils.isEmpty(activitySummary)) {
            helper.setText(R.id.tv_activity_ms,activitySummary);
        }


    }


}
